<?php


class Profil extends Controller {
	
	function Profil()
	{
		parent::Controller();
		
		$this->load->model('collection');
		$this->load->model('frame');
		$this->load->model('identification');
		
		$this->load->helper('file');
		$this->load->helper('form');
	}
	
	function index()
	{
		$data['title'] = "Profil";
		if (!empty($_SESSION['ID']))
		{
			$this->load->view('render/identifier', $data);
		}
		else
		{
			$this->load->view('render/user', $data);
		}
	}
	
	function NewUser()
	{
		//$this->identification->insert($mailNew, $nomNew,$prenomNew, $passwordNew);
		//$test = $this->load->$mailNew;
		//echo $test;
		$Mail = $_POST['mailNew'];
		$Nom = $_POST['nomNew'];
		$Prenom = $_POST['prenomNew'];
		$MDP = $_POST['passwordNew'];
		$this->identification->insert($Mail, $Nom,$Prenom, $MDP);
		/*$test = $_POST['prenomNew'];
		echo $_POST['prenomNew'];
		echo $test;
		$test = "KO";
		echo $test;*/




	}

	function UpdateUser()
	{
		if ($_POST['password'] == $_POST['password2'])
		{
			$Mail = $_POST['mail'];
			$Nom = $_POST['nom'];
			$Prenom = $_POST['prenom'];
			$MDP = $_POST['password'];
			$this->identification->Update($Mail, $Nom,$Prenom, $MDP);
		}
		else
		{
		echo "Les mots de passe ne correspondent pas";			
		$data['title'] = "Profil";
			
			$this->load->view('render/identifier', $data);
		}
	




	}
	function Identification()
	{
		$Mail = $_POST['mail'];
		$MDP = $_POST['password'];
		$this->identification->Log($Mail, $MDP);
	}
	function deconnexion()
	{
		session_destroy();
			$data['title'] = "Profil";
		$this->load->view('render/user', $data);
		redirect('/Profil/', 'refresh');
	}
}
?>
